// 计算分支数所占百分比
export default function stepPercentFn(x) {
  // 总长80, 0为4；
  if (x === 0) {
    return `${(4 / 80) * 100}%`;
  }
  // x >10000，宽度100%
  if (x > 10000) {
    return '100%';
  }
  // 宽度计算 width = (x-a) * (d-c) / (b-a) + c;
  // 比如1001-10000之间，宽度为60-80之间
  // x为提交数; a为1001， 10000为b; c为60, d为80；
  let a;
  let b;
  let c;
  let d;
  if (x <= 10) {
    a = 1;
    b = 10;
    c = 4;
    d = 20;
  } else if (x <= 100) {
    a = 11;
    b = 100;
    c = 20;
    d = 40;
  } else if (x <= 1000) {
    a = 101;
    b = 1000;
    c = 40;
    d = 60;
  } else {
    a = 1001;
    b = 10000;
    c = 60;
    d = 80;
  }
  const length = ((x - a) * (d - c)) / (b - a) + c;
  return `${(length / 80) * 100}%`;
}
